package com.awaken.content.service.impl;

import com.awaken.content.models.dto.ProductDTO;
import com.awaken.content.models.request.ProductRequest;
import com.awaken.content.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 商品服务实现类
 *
 * @author awaken-lin
 */
@Slf4j
@Service
public class ProductServiceImpl implements ProductService {

    @Override
    public ProductDTO createProduct(ProductRequest request) {
        log.info("创建商品: {}", request);
        ProductDTO product = new ProductDTO();
        product.setId(1L);
        product.setName(request.getName());
        product.setPrice(new BigDecimal("99.99"));
        product.setStock(100);
        product.setCategoryId(1L);
        product.setSellerId(1L);
        product.setCreateTime(LocalDateTime.now());
        return product;
    }

    @Override
    public ProductDTO getProductById(Long id) {
        log.info("获取商品信息: {}", id);
        ProductDTO product = new ProductDTO();
        product.setId(id);
        product.setName("示例商品");
        product.setPrice(new BigDecimal("99.99"));
        product.setStock(100);
        product.setCategoryId(1L);
        product.setSellerId(1L);
        product.setCreateTime(LocalDateTime.now());
        return product;
    }

    @Override
    public List<ProductDTO> getAllProducts() {
        log.info("获取所有商品列表");
        List<ProductDTO> products = new ArrayList<>();
        ProductDTO product = new ProductDTO();
        product.setId(1L);
        product.setName("示例商品");
        product.setPrice(new BigDecimal("99.99"));
        product.setStock(100);
        product.setCategoryId(1L);
        product.setSellerId(1L);
        product.setCreateTime(LocalDateTime.now());
        products.add(product);
        return products;
    }

    @Override
    public List<ProductDTO> getProductsByCategory(Long categoryId) {
        log.info("获取分类商品列表: {}", categoryId);
        List<ProductDTO> products = new ArrayList<>();
        ProductDTO product = new ProductDTO();
        product.setId(1L);
        product.setName("示例商品");
        product.setPrice(new BigDecimal("99.99"));
        product.setStock(100);
        product.setCategoryId(categoryId);
        product.setSellerId(1L);
        product.setCreateTime(LocalDateTime.now());
        products.add(product);
        return products;
    }

    @Override
    public boolean updateStock(Long productId, Integer amount) {
        log.info("更新商品库存: productId={}, amount={}", productId, amount);
        return true;
    }
} 